layui.define(['table', 'form','laypage','laydate','layer'], function(exports) {
    var $ = layui.$
        , table = layui.table
        , form = layui.form
        , laydate = layui.laydate
        , laypage = layui.laypage
        , layer = layui.layer;

    //路径
    var curWwwPath = window.document.location.href;
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    var localhostPaht = curWwwPath.substring(0, pos);
    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);

    var limitcount =10;
    table.render({
        elem: '#data'
        , url:  localhostPaht+projectName+"/rest/system/getStructureDetail"
        , height: 'full-145'
        , page: false
        , limit: limitcount
        , title:"数据库字典列表"
        , text: {
            none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
        }
        , loading:true
        , toolbar: '#dataDemo'
        , defaultToolbar: ['filter', 'print']
        // ,skin: 'line' //表格风格
        , cols: [[
            // {type: 'checkbox'}
            {field: 'number', title: 'ID', width: 70, sort: true,fixed:'left'}
            , {field: 'selectName', title: '代码类别值', sort: true}
            // , {field: 'optionCode', title: '代码值', sort: true}
            , {field: 'optionName', title: '代码值名称', sort: true}
            , {field: 'createTime', title: '创建时间', sort: true}
            // , {title: '操作', toolbar: '#table-useradmin-webuser',align: "center",minwidth: 200}
        ]],
        where: {
            id:"1",
        },
        done: function (res, curr, count) {
            if(res.errorMsg==null){

            }else {
                layer.msg(res.errorMsg);
            }
            $('.layui-table-fixed-r').removeClass('layui-hide');//列固定右侧
            var curnum = $("#curnum").val();
            laypage.render({
                elem: 'laypage'
                ,first: '首页'
                ,last: '尾页'
                ,groups:5
                , count: count
                , curr: curnum
                , limit: limitcount
                , layout: ['prev', 'page', 'next', 'skip', 'count','limit']
                , limits:[10,15,20]
                , jump: function (obj, first) {
                    if (!first) {
                        curnum = obj.curr;
                        $("#curnum").val(curnum)
                        limitcount = obj.limit;
                        table.reload('data', { //表格的id
                            where: {
                                page: curnum,
                                limit:limitcount
                            }
                        })

                    }
                }
            })
        }

    });

    exports('datadictionary', {})
});
